from django.db import models

from utils.BaseModel import BaseModel
from home.models import CategoryModel

# Create your models here.
# 教师的模型类
class TeacherModel(BaseModel):
    name=models.CharField(max_length=20,verbose_name='教师名称')
    job=models.CharField(max_length=20,verbose_name='教师职称')
    intro=models.TextField(verbose_name='教师简介')
    headimg=models.CharField(max_length=200,verbose_name='教师头像')
    class Meta:
        db_table='fgteacher'
    def __str__(self):
        return self.name
#     课程分类模型类
class CourseModel(BaseModel):
    name=models.CharField(max_length=20,verbose_name="课程名称")
    category=models.ForeignKey(CategoryModel,on_delete=models.SET_NULL,null=True,blank=True)
    teacher=models.ForeignKey(TeacherModel,on_delete=models.SET_NULL,null=True,blank=True)
    intro=models.TextField(verbose_name='课程简介')
    price=models.DecimalField(max_digits=10,decimal_places=2,verbose_name='课程价格')
    timeline=models.IntegerField(default=0)
    counts=models.IntegerField(default=0)
    isgoods=models.BooleanField(default=False,verbose_name='是否为精品')
    ishot=models.BooleanField(default=False,verbose_name='是否热销')
    ishome=models.BooleanField(default=False,verbose_name='是否推荐到首页广告')
    level=models.IntegerField(choices=((0,'初级'),(1,'中级'),(2,'高级')),default=0)
    cover=models.CharField(max_length=200,verbose_name='课程封面')
    video=models.CharField(max_length=200,verbose_name='课程简介视频')
    score=models.FloatField(default=10.0,verbose_name='评分')
    class Meta:
        db_table='fgcourse'
    def __str__(self):
        return self.name

